/**
 * 后续拜访
 * Created by wenchuan.li on 2018/07/13 11:13.
 */
define(function () {

    var self, vue,
        app = win.app,
        subData = {
            GWBH019: '',//下次拜访预计开始时间
            GWBH020: '',//下次拜访预计结束时间
            GWBH021: '',//下次拜访人员姓名
            GWBH022: '',//下次拜访人员职位编号
            GWBH023: '',//下次拜访人员角色编号
            GWBH024: '',//下次拜访地址
            GWBH025: '',//下次拜访目的
            GWBH026: '',//下次拜访内容
        },
        pageParameters
    ;

    var Hxbf = app.Module.extend({

        init: function () {
            self = this;
            self._super({
                _scroll: '.mui-scroll-wrapper',
                _readyBefore: function () {
                    pageParameters = self._pageParameters;
                }
            }, win);
            app.extend(subData, pageParameters.hxbfData);
        },

        _lazy: function () {
            this._super();
            if(!app.isEmpty(subData.GWBH019)){
                subData.GWBH019 = (new Date(subData.GWBH019)).Format("yyyy-MM-ddThh:mm");
            }
            if(!app.isEmpty(subData.GWBH020)){
                subData.GWBH020 = (new Date(subData.GWBH020)).Format("yyyy-MM-ddThh:mm");
            }
            vue = new Vue({
                el: app.getByid(doc, 'content'),
                data: {
                    sub: subData,
                    GWBHACTI: pageParameters.GWBHACTI,
                    from:pageParameters._from,
                },
                methods: {
                    showmsg: function () {
                        app.toast('该拜访记录已经审核，无法修改');
                        return;
                    },
                    toBack: function () {
                        app.back(1);
                    },
                    editHxbf: function () {
                        if (subData.GWBH021.trim() == '') {
                            app.toast('请选择预计拜访人');
                            return false;
                        }
                        if (subData.GWBH019.trim() == '') {
                            app.toast('请选择拜访开始时间');
                            return false;
                        }
                        if (subData.GWBH020.trim() == '') {
                            app.toast('请选择拜访结束时间');
                            return false;
                        }
                        if (subData.GWBH025.trim() == '') {
                            app.toast('请输入拜访目的');
                            return false;
                        }
                        if (subData.GWBH024.trim() == '') {
                            app.toast('请输入拜访地址');
                            return false;
                        }
                        if (subData.GWBH026.trim() == '') {
                            app.toast('请输入拜访内容');
                            return false;
                        }

                        app.extend(pageParameters.hxbfData, subData);
                        app.back(1);
                    },
                    selectBfr: function () {
                        app.openPage({
                            src: 'hn-bfjltb/bfr.html',
                            args: {
                                GWBIID: pageParameters.hxbfData.GWBHID,
                                GWBINAME: pageParameters.hxbfData.GWBHNAME,
                                cb: function (bfr) {
                                    subData.GWBH021 = bfr.GWBI002;//拜访人员姓名
                                    subData.GWBH022 = bfr.GWBI005;//拜访人员职位编号
                                    subData.GWBH023 = bfr.GWBI001;//拜访人员角色编号
                                }
                            }
                        });
                    }
                }
            });
        },
        _ready: function () {

        }
    });

    return new Hxbf();

});